/**
 * admui-basic v2.1.0 (http://www.admui.com/)
 * Copyright 2015-2019 Admui Team
 * Licensed under the Admui License 1.1 (http://www.admui.com/about/license)
 */
(function(window, document, $) {
  'use strict';

  /* global Breakpoints */

  window.App.extend({
    run: function() {
      var $nav = $('.site-navbar');
      var offsetTop = 0;
      var table;

      if ($nav.length > 0) {
        offsetTop = $nav.innerHeight();
      }

      table = $('#exampleFixedHeader').DataTable(
        $.concatCpt('dataTable', {
          pagingType: 'full_numbers',
          fixedHeader: {
            header: true,
            headerOffset: offsetTop
          }
        })
      );

      if (Breakpoints.is('xs')) {
        table.fixedHeader.disable();
      }

      Breakpoints.on('xs', 'leave', function() {
        table.fixedHeader.enable();
      });

      Breakpoints.on('sm', 'leave', function() {
        table.fixedHeader.disable();
      });
    }
  });

  window.App.run();
})(window, document, jQuery);
